﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;
namespace StoreWeb.system.storeCheckAccountMD
{
    public partial class list : System.Web.UI.Page
    {
        BLL.StoreCheckAccount userdealers = new BLL.StoreCheckAccount();
        Maticsoft.BLL.UserAdmin user = new Maticsoft.BLL.UserAdmin();
        //BLL.Role role = new BLL.Role();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //bindData(hidwhere.Value);
                String dealersid = user.GetModel(Convert.ToInt32(Request.Cookies["UserLogin"].Values[0])).dealersid;//经销商ID
                hidwhere.Value = " dealersid = '" + dealersid + "'";
                int totalOrders = userdealers.GetRecordCount(hidwhere.Value);
                AspNetPager1.RecordCount = totalOrders;
            }
        }
        void bindData(string where)
        {

            Repeater1.DataSource = userdealers.GetListByPage(where, " ", AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex);
            Repeater1.DataBind();
        }

        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            bindData(hidwhere.Value);
        }

        /// <summary>
        /// 获得门店名
        /// </summary>
        /// <param name="parentid"></param>
        /// <returns></returns>
        protected string GetDealersName(String dealersid)
        {
            if (dealersid == "" || dealersid == "0")
            {
                return "";
            }
            else
            {
                return new BLL.DealersManage().GetModel(Convert.ToInt32(dealersid)).username + "【" + new BLL.DealersManage().GetModel(Convert.ToInt32(dealersid)).dealersgrade + "级】";
                //return "";
            }
        }

        /// <summary>
        /// 获得用户名
        /// </summary>
        /// <param name="parentid"></param>
        /// <returns></returns>
        protected string GetUserName(String createuser)
        {
            if (createuser == "")
            {
                return "";
            }
            else
            {
                return new Maticsoft.BLL.UserAdmin().GetModel(Convert.ToInt32(createuser)).username;
            }
        }


        protected void btnserach_Click(object sender, EventArgs e)
        {
            
            string where = "1=1 ";
            if (type.Value != "")
            {
                where += " and type = '" + type.Value + "'";
            }
            //if (dealers.Value != null && !string.IsNullOrEmpty(dealers.Value))
            //{
            //    where += " and dealersid = '" + dealers.Value + "'";
            //}
            hidwhere.Value = where;
            bindData(hidwhere.Value);
        }

    }
}